package org.bt.common.validator;

import org.bt.common.validator.aspect.Mobile;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import java.util.Objects;

/**
 * IsMobileValidator
 * <p>
 * Created on 2020/1/8
 *
 * @author tongw
 */
public class MobileValidator implements ConstraintValidator<Mobile, String> {

    @Override
    public boolean isValid(String phone, ConstraintValidatorContext constraintValidatorContext) {
        if (Objects.isNull(phone)) {
            return true;
        }
        return ValidatorUtils.isMobile(phone);
    }
}
